package com.bwie.controller;

import com.bwie.service.TbUserService;
import com.bwie.utils.R;
import com.bwie.vo.LoginVo;
import com.bwie.vo.RegInfoVo;
import org.aspectj.lang.annotation.Pointcut;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

/**
 * @description : TODO
 * @Author QiHainan
 * @Create 2025/7/18 11:35
 * @Version 1.0
 */
@RestController
@RequestMapping("/auth/index")
public class IndexController {

    @Autowired
    TbUserService tbUserService;

    /**
     * 发送验证码
     * @param mobile
     * @return
     */
    @PostMapping("/sendCode/{mobile}")
    public R sendCode(@PathVariable("mobile") String mobile){
        return tbUserService.sendCode(mobile);
    }

    /**
     * 注册用户
     * @param regInfoVo
     * @return
     */
    @PostMapping("/regUser")
    public R regUser(@RequestBody @Validated RegInfoVo regInfoVo){
        return tbUserService.regUser(regInfoVo);
    }

    @PostMapping("/login")
    public R login(@RequestBody @Validated  LoginVo loginVo){
        return tbUserService.login(loginVo);
    }

    /**
     * 获取用户权限
     * @return
     */
    @PostMapping("/getMenuTree")
    public R getMenuTree(){
        return tbUserService.getMenuTree();
    }

    @PostMapping("/getUserInfoById/{userId}")
    public R getUserInfoById(@PathVariable("userId") Integer userId){
        return tbUserService.getUserInfoById(userId);
    }
}
